package com.ce.pms.system.custservice.dao.impl;

import static org.junit.Assert.assertEquals;
import junit.framework.TestCase;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.system.custservice.model.CustEventNatureDO;

public class PmsBaseDaoImplT extends TestCase
{

	private Mockery context = new Mockery() {{
        setImposteriser(ClassImposteriser.INSTANCE);
    }};
    TestDaoImpl mockDaoImpl = context.mock(TestDaoImpl.class);
    
	private TestDaoImpl daoImpl = new TestDaoImpl();
	
	@SuppressWarnings("unchecked")
	private Class clazz ; 
	@Before
	public void setUp() throws Exception
	{
		clazz = daoImpl.getClassType();
	}


	@After
	public void tearDown() throws Exception
	{
	}
	
	
	@Test
	public void testFindUniqueByName()
	{
		final String expectedName = "name";
		final CustEventNatureDO natureDO = new CustEventNatureDO();
		natureDO.setName(expectedName);
		context.checking(new Expectations(){{
			oneOf(mockDaoImpl).findUniqueByName(expectedName);will(returnValue(natureDO));
		}});
		CustEventNatureDO returnValue = mockDaoImpl.findUniqueByName(expectedName);
		context.assertIsSatisfied();
		assertEquals(expectedName, returnValue.getName());
	}


	@Test
	public void testGetClassType()
	{
		assertEquals(CustEventNatureDO.class.getSimpleName(), clazz.getSimpleName());
		//System.out.println(CustEventNatureDO.class.getSimpleName());
	}

	private class TestDaoImpl extends PmsBaseDaoImpl<CustEventNatureDO>
	{
		
	}
}
